// Copyright 2020 Poofee (https://github.com/Poofee)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------
/*****************************************************************************
 *                                                                           *
 *  File:    main.cpp                                                        *
 *                                                                           *
 *****************************************************************************
 *                                                                           *
 *  Authors: Poofee                                                          *
 *  Email:   poofee@qq.com                                                   *
 *  Address: https://github.com/Poofee                                       *
 *  Date:    2020年07月15日                                                   *
 *                                                                           *
 *****************************************************************************/


#include "relay1250.h"
#include "testremesh.h"

#include "slu_mt_ddefs.h"
#if !defined(ARMA_32BIT_WORD)
#define ARMA_32BIT_WORD
#endif
#include <armadillo> 

#include <stdio.h>

#include "valverelay.h"
#include "to5relay.h"
#include "coil3d.h"

using namespace arma;


enum Tests {
    TEST_1250_TIME_NR,
    TEST_1250_TIME_BBTLM,
    TEST_VALVE3D_NR,
    TEST_VALVE3D_TLM,
    TEST_TO53D_NR,
    TEST_TO53D_TLM,
    TEST_VALVE3D_TIME_NR_CPU,
    TEST_VALVE3D_TIME_TLM_CPU,
    TEST_VALVE3D_TIME_NR_GPU,
    TEST_VALVE3D_TIME_TLM_GPU,
    TEST_TO53D_TIME_NR_CPU,
    TEST_TO53D_TIME_TLM_CPU,
    TEST_TO53D_TIME_NR_GPU,
    TEST_TO53D_TIME_TLM_GPU,
    TEST_REMESH,
	COIL3D,
};

int main(int argc, char *argv[]) {
    /** 设置即时输出 **/
    setvbuf(stdout, 0, _IONBF, 0);
    int runWhat = TEST_TO53D_TIME_NR_CPU;

    if (runWhat == TEST_1250_TIME_NR) {
		Relay1250 r;
		r.TransientAnalysis();
    } else if (runWhat == TEST_1250_TIME_BBTLM) {
		Relay1250 r;
		r.TransientInitial();
		r.openGeo();
        r.MagnetoDynamics2DAxisBBTLM();
		r.outputResults();
    } else if (runWhat == TEST_VALVE3D_NR) {
		ValveRelay r;
		r.StaticAnalysis();
    } else if (runWhat == TEST_VALVE3D_TLM) {
		ValveRelay r;
		r.StaticInitial();
		r.openGeo();
        r.MagnetoStatic3DATLM();
		r.outputResults();
    } else if (runWhat == TEST_TO53D_NR) {
        to5Relay r;
		r.StaticAnalysis();
    } else if (runWhat == TEST_TO53D_TLM) {
		to5Relay r;
		r.StaticInitial();
		r.openGeo();
        r.MagnetoStatic3DATLM();
		r.outputResults();
    } else if (runWhat == TEST_VALVE3D_TIME_NR_CPU) {
		ValveRelay r;
		r.TransientAnalysis();
    } else if (runWhat == TEST_VALVE3D_TIME_TLM_CPU) {
		ValveRelay r;
		r.TransientInitial();
		r.openGeo();
		r.outputResults();
    } else if (runWhat == TEST_VALVE3D_TIME_NR_GPU) {
		ValveRelay r;
		r.TransientInitial();
		r.openGeo();
		r.outputResults();
    } else if (runWhat == TEST_VALVE3D_TIME_TLM_GPU) {
		ValveRelay r;
		r.TransientInitial();
		r.openGeo();
		r.outputResults();
    } else if (runWhat == TEST_TO53D_TIME_NR_CPU) {
		to5Relay r;
		r.TransientAnalysis();
    } else if (runWhat == TEST_TO53D_TIME_TLM_CPU) {
		to5Relay r;
		r.TransientInitial();
		r.openGeo();
		r.outputResults();
    } else if (runWhat == TEST_TO53D_TIME_NR_GPU) {
		to5Relay r;
		r.TransientInitial();
		r.openGeo();
		r.outputResults();
    } else if (runWhat == TEST_TO53D_TIME_TLM_GPU) {
		to5Relay r;
		r.TransientInitial();
		r.openGeo();
		r.outputResults();
	} else if (runWhat == COIL3D) {
		Coil3D c;
		c.run();
    } else if (runWhat == TEST_REMESH) {
		testRemesh tr;
//		tr.testRemesh2D();
//        tr.testRemesh3DRotate();
//		tr.testRemesh3DParallel();
        tr.testMove3DMeshParallel();
//		tr.testRotate3DMesh();
	}

    printf("Hello world!\n");
	return 0;
}
